package com.rengl.controller;

import com.rengl.model.User;
import com.rengl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("admin/user")
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${user}")
    private String userStr;

    @GetMapping("hi")
    public String hi(){
        return "hi";
    }

    @PostMapping("add")
    public void add(@RequestBody User user){

        userService.add(user);
    }

    @GetMapping("list")
    public List<User> list(){

        System.out.println("从gitee上拉去到了配置文件,并读取到内容:" + userStr);

        List<User> userList = userService.list();
        return userList;
    }
}
